/*
 *------------------------------------------------------------------------------
 * @File      :    lt8912b_mipi.c
 * @Date      :    2021-3-20
 * @Author    :    lomboswer <lomboswer@lombotech.com>
 * @Brief     :    Source file for MDP(Media Development Platform).
 *
 * Copyright (C) 2020-2021, LomboTech Co.Ltd. All rights reserved.
 *------------------------------------------------------------------------------
 */
#include "ei_comm_panel.h"
#include <fcntl.h>
#include "panel_usr.h"
#include "ei_math.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

#define T1_WIDTH	(720)
#define T1_HEIGHT	(480)
#define T1_VIC		(2)
#define T1_HBP		(60)
#define T1_HFP		(16)
#define T1_HSW		(62)
#define T1_HACT		(T1_WIDTH)
#define T1_HT		(T1_HFP + T1_HSW + T1_HBP + T1_HACT)
#define T1_VBP_F1	(30)
#define T1_VFP_F1	(9)
#define T1_VSW_F1	(6)
#define T1_VACT_F1	(T1_HEIGHT)
#define T1_VT_F1	(T1_VBP_F1 + T1_VFP_F1 + T1_VSW_F1 + T1_VACT_F1)
#define T1_VBP_F2	(0)
#define T1_VFP_F2	(0)
#define T1_VSW_F2	(0)
#define T1_VACT_F2	(0)
#define T1_VT_F2	(T1_VBP_F2 + T1_VFP_F2 + T1_VSW_F2 + T1_VACT_F2)
#define T1_DCLK		(27000000)

#define T2_WIDTH	(1280)
#define T2_HEIGHT	(720)
#define T2_VIC		(19)
#define T2_HBP		(220)
#define T2_HFP		(440)
#define T2_HSW		(40)
#define T2_HACT		(T2_WIDTH)
#define T2_HT		(T2_HFP + T2_HSW + T2_HBP + T2_HACT)
#define T2_VBP_F1	(20)
#define T2_VFP_F1	(5)
#define T2_VSW_F1	(5)
#define T2_VACT_F1	(T2_HEIGHT)
#define T2_VT_F1	(T2_VBP_F1 + T2_VFP_F1 + T2_VSW_F1 + T2_VACT_F1)
#define T2_VBP_F2	(0)
#define T2_VFP_F2	(0)
#define T2_VSW_F2	(0)
#define T2_VACT_F2	(0)
#define T2_VT_F2	(T2_VBP_F2 + T2_VFP_F2 + T2_VSW_F2 + T2_VACT_F2)
#define T2_DCLK		(74250000)

#define T3_WIDTH	(1920)
#define T3_HEIGHT	(1080)
#define T3_VIC		(16)
#define T3_HBP		(148)
#define T3_HFP		(88)
#define T3_HSW		(44)
#define T3_HACT		(T3_WIDTH)
#define T3_HT		(T3_HFP + T3_HSW + T3_HBP + T3_HACT)
#define T3_VBP_F1	(36)
#define T3_VFP_F1	(4)
#define T3_VSW_F1	(5)
#define T3_VACT_F1	(T3_HEIGHT)
#define T3_VT_F1	(T3_VBP_F1 + T3_VFP_F1 + T3_VSW_F1 + T3_VACT_F1)
#define T3_VBP_F2	(0)
#define T3_VFP_F2	(0)
#define T3_VSW_F2	(0)
#define T3_VACT_F2	(0)
#define T3_VT_F2	(T3_VBP_F2 + T3_VFP_F2 + T3_VSW_F2 + T3_VACT_F2)
#define T3_DCLK		(148500000)

#define LANE_NUM	(4)

static VO_PUB_ATTR_S lt8912b_720_480_60_config = {
    .enIntfType = VO_INTF_MIPI,
    .enIntfSync = VO_OUTPUT_USER,
    .BufferSmooth = (-1U),

    .stSyncInfo.lane_id = {0, 1, 2, 3},
    .stSyncInfo.output_mode = OUTPUT_MODE_DSI_VIDEO,
    .stSyncInfo.output_format = OUT_FORMAT_RGB_24_BIT,
    .stSyncInfo.video_mode =  NON_BURST_MODE_SYNC_PULSES,
    .stSyncInfo.bIop = 1,
    .stSyncInfo.u16Hfb = T1_HFP,
    .stSyncInfo.u16Hpw = T1_HSW,
    .stSyncInfo.u16Hbb = T1_HBP,
    .stSyncInfo.u16Hact = T1_HACT,
    .stSyncInfo.u16Vfb = T1_VFP_F1,
    .stSyncInfo.u16Vpw = T1_VSW_F1,
    .stSyncInfo.u16Vbb = T1_VBP_F1,
    .stSyncInfo.u16Vact = T1_VACT_F1,
    .stSyncInfo.u32Pclk = (T1_DCLK / 1000),
};

static VO_PUB_ATTR_S lt8912b_1280_720_50_config = {
    .enIntfType = VO_INTF_MIPI,
    .enIntfSync = VO_OUTPUT_USER,
    .BufferSmooth = (-1U),

    .stSyncInfo.lane_id = {0, 1, 2, 3},
    .stSyncInfo.output_mode = OUTPUT_MODE_DSI_VIDEO,
    .stSyncInfo.output_format = OUT_FORMAT_RGB_24_BIT,
    .stSyncInfo.video_mode =  NON_BURST_MODE_SYNC_PULSES,
    .stSyncInfo.bIop = 1,
    .stSyncInfo.u16Hfb = T2_HFP,
    .stSyncInfo.u16Hpw = T2_HSW,
    .stSyncInfo.u16Hbb = T2_HBP,
    .stSyncInfo.u16Hact = T2_HACT,
    .stSyncInfo.u16Vfb = T2_VFP_F1,
    .stSyncInfo.u16Vpw = T2_VSW_F1,
    .stSyncInfo.u16Vbb = T2_VBP_F1,
    .stSyncInfo.u16Vact = T2_VACT_F1,
    .stSyncInfo.u32Pclk = (T2_DCLK / 1000),
};

static VO_PUB_ATTR_S lt8912b_1920_1080_60_config = {
    .enIntfType = VO_INTF_MIPI,
    .enIntfSync = VO_OUTPUT_USER,
    .BufferSmooth = (-1U),

    .stSyncInfo.lane_id = {0, 1, 2, 3},
    .stSyncInfo.output_mode = OUTPUT_MODE_DSI_VIDEO,
    .stSyncInfo.output_format = OUT_FORMAT_RGB_24_BIT,
    .stSyncInfo.video_mode =  NON_BURST_MODE_SYNC_PULSES,
    .stSyncInfo.bIop = 1,
    .stSyncInfo.u16Hfb = T3_HFP,
    .stSyncInfo.u16Hpw = T3_HSW,
    .stSyncInfo.u16Hbb = T3_HBP,
    .stSyncInfo.u16Hact = T3_HACT,
    .stSyncInfo.u16Vfb = T3_VFP_F1,
    .stSyncInfo.u16Vpw = T3_VSW_F1,
    .stSyncInfo.u16Vbb = T3_VBP_F1,
    .stSyncInfo.u16Vact = T3_VACT_F1,
    .stSyncInfo.u32Pclk = (T3_DCLK / 1000),
};

static unsigned char lt8912b_480P_init_code[] = {
    3, 0x90, 0x08, 0xff,
    3, 0x90, 0x09, 0x81,
    3, 0x90, 0x0a, 0xff,
    3, 0x90, 0x0b, 0x64,
    3, 0x90, 0x0c, 0xff,
    3, 0x90, 0x44, 0x31,
    3, 0x90, 0x51, 0x1f,
    3, 0x90, 0x31, 0xa1,
    3, 0x90, 0x32, 0xbf,
    3, 0x90, 0x33, 0x17,
    3, 0x90, 0x37, 0x00,
    3, 0x90, 0x38, 0x22,
    3, 0x90, 0x60, 0x82,
    3, 0x90, 0x3a, 0x00,
    3, 0x90, 0x39, 0x45,
    3, 0x90, 0x3b, 0x00,
    3, 0x90, 0x44, 0x31,
    3, 0x90, 0x55, 0x44,
    3, 0x90, 0x57, 0x01,
    3, 0x90, 0x5a, 0x02,
    3, 0x92, 0x10, 0x01,
    3, 0x92, 0x11, 0x08,
    3, 0x92, 0x12, 0x04,
    3, 0x92, 0x13, (LANE_NUM % 0x04),
    3, 0x92, 0x14, 0x00,
    3, 0x92, 0x15, 0x00,
    3, 0x92, 0x1a, 0x03,
    3, 0x92, 0x1b, 0x03,
    3, 0x92, 0x1e, 0x67,
    3, 0x92, 0x2f, 0x0c,
    3, 0x92, 0x4e, 0x52,
    3, 0x92, 0x4f, 0xde,
    3, 0x92, 0x50, 0xc0,
    3, 0x92, 0x51, 0x80,
    3, 0x92, 0x51, 0x00,
    3, 0x92, 0x1f, 0x5e,
    3, 0x92, 0x20, 0x01,
    3, 0x92, 0x21, 0x2c,
    3, 0x92, 0x22, 0x01,
    3, 0x92, 0x23, 0xfa,
    3, 0x92, 0x24, 0x00,
    3, 0x92, 0x25, 0xc8,
    3, 0x92, 0x26, 0x00,
    3, 0x92, 0x27, 0x5e,
    3, 0x92, 0x28, 0x01,
    3, 0x92, 0x29, 0x2c,
    3, 0x92, 0x2a, 0x01,
    3, 0x92, 0x2b, 0xfa,
    3, 0x92, 0x2c, 0x00,
    3, 0x92, 0x2d, 0xc8,
    3, 0x92, 0x2e, 0x00,
    3, 0x90, 0x03, 0x7f,
    0, 100,
    3, 0x90, 0x03, 0xff,
    3, 0x92, 0x42, 0x64,
    3, 0x92, 0x43, 0x00,
    3, 0x92, 0x44, 0x04,
    3, 0x92, 0x45, 0x00,
    3, 0x92, 0x46, 0x59,
    3, 0x92, 0x47, 0x00,
    3, 0x92, 0x48, 0xf2,
    3, 0x92, 0x49, 0x06,
    3, 0x92, 0x4a, 0x00,
    3, 0x92, 0x4b, 0x72,
    3, 0x92, 0x4c, 0x45,
    3, 0x92, 0x4d, 0x00,
    3, 0x92, 0x52, 0x08,
    3, 0x92, 0x53, 0x00,
    3, 0x92, 0x54, 0xb2,
    3, 0x92, 0x55, 0x00,
    3, 0x92, 0x56, 0xe4,
    3, 0x92, 0x57, 0x0d,
    3, 0x92, 0x58, 0x00,
    3, 0x92, 0x59, 0xe4,
    3, 0x92, 0x5a, 0x8a,
    3, 0x92, 0x5b, 0x00,
    3, 0x92, 0x5c, 0x34,
    3, 0x92, 0x1e, 0x4f,
    3, 0x92, 0x51, 0x00,
    3, 0x90, 0xB2, 0x01,
    3, 0x94, 0x06, 0x08,
    3, 0x94, 0x07, 0xF0,
    3, 0x94, 0x34, 0xE2,
    3, 0x94, 0x3c, 0x41,
    3, 0x94, 0x3e, 0x0A,
    3, 0x90, 0x03, 0x7f,
    0, 100,
    3, 0x90, 0x03, 0xff,
    3, 0x92, 0x51, 0x80,
    0, 100,
    3, 0x92, 0x51, 0x00,
    3, 0x94, 0x44, 0x10,
    3, 0x94, 0x45, 0x2A,
    /* the above is common init code */
    3, 0x92, 0x18, (unsigned char)(T1_HSW % 256),
    3, 0x92, 0x19, (unsigned char)(T1_VSW_F1 % 256),
    3, 0x92, 0x1c, (unsigned char)(T1_HACT % 256),
    3, 0x92, 0x1d, (unsigned char)(T1_HACT / 256),
    3, 0x92, 0x34, (unsigned char)((T1_HT) % 256),
    3, 0x92, 0x35, (unsigned char)((T1_HT) / 256),
    3, 0x92, 0x36, (unsigned char)((T1_VT_F1) % 256),
    3, 0x92, 0x37, (unsigned char)((T1_VT_F1) / 256),
    3, 0x92, 0x38, (unsigned char)(T1_VBP_F1 % 256),
    3, 0x92, 0x39, (unsigned char)(T1_VBP_F1 / 256),
    3, 0x92, 0x3a, (unsigned char)(T1_VFP_F1 % 256),
    3, 0x92, 0x3b, (unsigned char)(T1_VFP_F1 / 256),
    3, 0x92, 0x3c, (unsigned char)(T1_HBP % 256),
    3, 0x92, 0x3d, (unsigned char)(T1_HBP / 256),
    3, 0x92, 0x3e, (unsigned char)(T1_HFP % 256),
    3, 0x92, 0x3f, (unsigned char)(T1_HFP / 256),
    /*
     * reg[0x43] is checksums, it will be changed
     * after reg[0x45] or reg[0x47] changed.
     * regs 0x43, 0x44, 0x45, 0x47 total sum is 0x6F.
     */
    3, 0x94, 0x43, 0x33,
    3, 0x94, 0x47, T1_VIC,
};

static unsigned char lt8912b_720P_init_code[] = {
    3, 0x90, 0x08, 0xff,
    3, 0x90, 0x09, 0x81,
    3, 0x90, 0x0a, 0xff,
    3, 0x90, 0x0b, 0x64,
    3, 0x90, 0x0c, 0xff,
    3, 0x90, 0x44, 0x31,
    3, 0x90, 0x51, 0x1f,
    3, 0x90, 0x31, 0xa1,
    3, 0x90, 0x32, 0xbf,
    3, 0x90, 0x33, 0x17,
    3, 0x90, 0x37, 0x00,
    3, 0x90, 0x38, 0x22,
    3, 0x90, 0x60, 0x82,
    3, 0x90, 0x3a, 0x00,
    3, 0x90, 0x39, 0x45,
    3, 0x90, 0x3b, 0x00,
    3, 0x90, 0x44, 0x31,
    3, 0x90, 0x55, 0x44,
    3, 0x90, 0x57, 0x01,
    3, 0x90, 0x5a, 0x02,
    3, 0x92, 0x10, 0x01,
    3, 0x92, 0x11, 0x08,
    3, 0x92, 0x12, 0x04,
    3, 0x92, 0x13, (LANE_NUM % 0x04),
    3, 0x92, 0x14, 0x00,
    3, 0x92, 0x15, 0x00,
    3, 0x92, 0x1a, 0x03,
    3, 0x92, 0x1b, 0x03,
    3, 0x92, 0x1e, 0x67,
    3, 0x92, 0x2f, 0x0c,
    3, 0x92, 0x4e, 0x52,
    3, 0x92, 0x4f, 0xde,
    3, 0x92, 0x50, 0xc0,
    3, 0x92, 0x51, 0x80,
    3, 0x92, 0x51, 0x00,
    3, 0x92, 0x1f, 0x5e,
    3, 0x92, 0x20, 0x01,
    3, 0x92, 0x21, 0x2c,
    3, 0x92, 0x22, 0x01,
    3, 0x92, 0x23, 0xfa,
    3, 0x92, 0x24, 0x00,
    3, 0x92, 0x25, 0xc8,
    3, 0x92, 0x26, 0x00,
    3, 0x92, 0x27, 0x5e,
    3, 0x92, 0x28, 0x01,
    3, 0x92, 0x29, 0x2c,
    3, 0x92, 0x2a, 0x01,
    3, 0x92, 0x2b, 0xfa,
    3, 0x92, 0x2c, 0x00,
    3, 0x92, 0x2d, 0xc8,
    3, 0x92, 0x2e, 0x00,
    3, 0x90, 0x03, 0x7f,
    0, 100,
    3, 0x90, 0x03, 0xff,
    3, 0x92, 0x42, 0x64,
    3, 0x92, 0x43, 0x00,
    3, 0x92, 0x44, 0x04,
    3, 0x92, 0x45, 0x00,
    3, 0x92, 0x46, 0x59,
    3, 0x92, 0x47, 0x00,
    3, 0x92, 0x48, 0xf2,
    3, 0x92, 0x49, 0x06,
    3, 0x92, 0x4a, 0x00,
    3, 0x92, 0x4b, 0x72,
    3, 0x92, 0x4c, 0x45,
    3, 0x92, 0x4d, 0x00,
    3, 0x92, 0x52, 0x08,
    3, 0x92, 0x53, 0x00,
    3, 0x92, 0x54, 0xb2,
    3, 0x92, 0x55, 0x00,
    3, 0x92, 0x56, 0xe4,
    3, 0x92, 0x57, 0x0d,
    3, 0x92, 0x58, 0x00,
    3, 0x92, 0x59, 0xe4,
    3, 0x92, 0x5a, 0x8a,
    3, 0x92, 0x5b, 0x00,
    3, 0x92, 0x5c, 0x34,
    3, 0x92, 0x1e, 0x4f,
    3, 0x92, 0x51, 0x00,
    3, 0x90, 0xB2, 0x01,
    3, 0x94, 0x06, 0x08,
    3, 0x94, 0x07, 0xF0,
    3, 0x94, 0x34, 0xE2,
    3, 0x94, 0x3c, 0x41,
    3, 0x94, 0x3e, 0x0A,
    3, 0x90, 0x03, 0x7f,
    0, 100,
    3, 0x90, 0x03, 0xff,
    3, 0x92, 0x51, 0x80,
    0, 100,
    3, 0x92, 0x51, 0x00,
    3, 0x94, 0x44, 0x10,
    3, 0x94, 0x45, 0x2A,
    /* the above is common init code */
    3, 0x92, 0x18, (unsigned char)(T2_HSW % 256),
    3, 0x92, 0x19, (unsigned char)(T2_VSW_F1 % 256),
    3, 0x92, 0x1c, (unsigned char)(T2_HACT % 256),
    3, 0x92, 0x1d, (unsigned char)(T2_HACT / 256),
    3, 0x92, 0x34, (unsigned char)((T2_HT) % 256),
    3, 0x92, 0x35, (unsigned char)((T2_HT) / 256),
    3, 0x92, 0x36, (unsigned char)((T2_VT_F1) % 256),
    3, 0x92, 0x37, (unsigned char)((T2_VT_F1) / 256),
    3, 0x92, 0x38, (unsigned char)(T2_VBP_F1 % 256),
    3, 0x92, 0x39, (unsigned char)(T2_VBP_F1 / 256),
    3, 0x92, 0x3a, (unsigned char)(T2_VFP_F1 % 256),
    3, 0x92, 0x3b, (unsigned char)(T2_VFP_F1 / 256),
    3, 0x92, 0x3c, (unsigned char)(T2_HBP % 256),
    3, 0x92, 0x3d, (unsigned char)(T2_HBP / 256),
    3, 0x92, 0x3e, (unsigned char)(T2_HFP % 256),
    3, 0x92, 0x3f, (unsigned char)(T2_HFP / 256),
    /*
     * reg[0x43] is checksums, it will be changed
     * after reg[0x45] or reg[0x47] changed.
     * regs 0x43, 0x44, 0x45, 0x47 total sum is 0x6F.
     */
    3, 0x94, 0x43, 0x33,
    3, 0x94, 0x47, T2_VIC,
};

static unsigned char lt8912b_1080P_init_code[] = {
    3, 0x90, 0x08, 0xff,
    3, 0x90, 0x09, 0x81,
    3, 0x90, 0x0a, 0xff,
    3, 0x90, 0x0b, 0x64,
    3, 0x90, 0x0c, 0xff,
    3, 0x90, 0x44, 0x31,
    3, 0x90, 0x51, 0x1f,
    3, 0x90, 0x31, 0xa1,
    3, 0x90, 0x32, 0xbf,
    3, 0x90, 0x33, 0x17,
    3, 0x90, 0x37, 0x00,
    3, 0x90, 0x38, 0x22,
    3, 0x90, 0x60, 0x82,
    3, 0x90, 0x3a, 0x00,
    3, 0x90, 0x39, 0x45,
    3, 0x90, 0x3b, 0x00,
    3, 0x90, 0x44, 0x31,
    3, 0x90, 0x55, 0x44,
    3, 0x90, 0x57, 0x01,
    3, 0x90, 0x5a, 0x02,
    3, 0x92, 0x10, 0x01,
    3, 0x92, 0x11, 0x08,
    3, 0x92, 0x12, 0x04,
    3, 0x92, 0x13, (LANE_NUM % 0x04),
    3, 0x92, 0x14, 0x00,
    3, 0x92, 0x15, 0x00,
    3, 0x92, 0x1a, 0x03,
    3, 0x92, 0x1b, 0x03,
    3, 0x92, 0x1e, 0x67,
    3, 0x92, 0x2f, 0x0c,
    3, 0x92, 0x4e, 0x52,
    3, 0x92, 0x4f, 0xde,
    3, 0x92, 0x50, 0xc0,
    3, 0x92, 0x51, 0x80,
    3, 0x92, 0x51, 0x00,
    3, 0x92, 0x1f, 0x5e,
    3, 0x92, 0x20, 0x01,
    3, 0x92, 0x21, 0x2c,
    3, 0x92, 0x22, 0x01,
    3, 0x92, 0x23, 0xfa,
    3, 0x92, 0x24, 0x00,
    3, 0x92, 0x25, 0xc8,
    3, 0x92, 0x26, 0x00,
    3, 0x92, 0x27, 0x5e,
    3, 0x92, 0x28, 0x01,
    3, 0x92, 0x29, 0x2c,
    3, 0x92, 0x2a, 0x01,
    3, 0x92, 0x2b, 0xfa,
    3, 0x92, 0x2c, 0x00,
    3, 0x92, 0x2d, 0xc8,
    3, 0x92, 0x2e, 0x00,
    3, 0x90, 0x03, 0x7f,
    0, 100,
    3, 0x90, 0x03, 0xff,
    3, 0x92, 0x42, 0x64,
    3, 0x92, 0x43, 0x00,
    3, 0x92, 0x44, 0x04,
    3, 0x92, 0x45, 0x00,
    3, 0x92, 0x46, 0x59,
    3, 0x92, 0x47, 0x00,
    3, 0x92, 0x48, 0xf2,
    3, 0x92, 0x49, 0x06,
    3, 0x92, 0x4a, 0x00,
    3, 0x92, 0x4b, 0x72,
    3, 0x92, 0x4c, 0x45,
    3, 0x92, 0x4d, 0x00,
    3, 0x92, 0x52, 0x08,
    3, 0x92, 0x53, 0x00,
    3, 0x92, 0x54, 0xb2,
    3, 0x92, 0x55, 0x00,
    3, 0x92, 0x56, 0xe4,
    3, 0x92, 0x57, 0x0d,
    3, 0x92, 0x58, 0x00,
    3, 0x92, 0x59, 0xe4,
    3, 0x92, 0x5a, 0x8a,
    3, 0x92, 0x5b, 0x00,
    3, 0x92, 0x5c, 0x34,
    3, 0x92, 0x1e, 0x4f,
    3, 0x92, 0x51, 0x00,
    3, 0x90, 0xB2, 0x01,
    3, 0x94, 0x06, 0x08,
    3, 0x94, 0x07, 0xF0,
    3, 0x94, 0x34, 0xE2,
    3, 0x94, 0x3c, 0x41,
    3, 0x94, 0x3e, 0x0A,
    3, 0x90, 0x03, 0x7f,
    0, 100,
    3, 0x90, 0x03, 0xff,
    3, 0x92, 0x51, 0x80,
    0, 100,
    3, 0x92, 0x51, 0x00,
    3, 0x94, 0x44, 0x10,
    3, 0x94, 0x45, 0x2A,
    /* the above is common init code */
    3, 0x92, 0x18, (unsigned char)(T3_HSW % 256),
    3, 0x92, 0x19, (unsigned char)(T3_VSW_F1 % 256),
    3, 0x92, 0x1c, (unsigned char)(T3_HACT % 256),
    3, 0x92, 0x1d, (unsigned char)(T3_HACT / 256),
    3, 0x92, 0x34, (unsigned char)((T3_HT) % 256),
    3, 0x92, 0x35, (unsigned char)((T3_HT) / 256),
    3, 0x92, 0x36, (unsigned char)((T3_VT_F1) % 256),
    3, 0x92, 0x37, (unsigned char)((T3_VT_F1) / 256),
    3, 0x92, 0x38, (unsigned char)(T3_VBP_F1 % 256),
    3, 0x92, 0x39, (unsigned char)(T3_VBP_F1 / 256),
    3, 0x92, 0x3a, (unsigned char)(T3_VFP_F1 % 256),
    3, 0x92, 0x3b, (unsigned char)(T3_VFP_F1 / 256),
    3, 0x92, 0x3c, (unsigned char)(T3_HBP % 256),
    3, 0x92, 0x3d, (unsigned char)(T3_HBP / 256),
    3, 0x92, 0x3e, (unsigned char)(T3_HFP % 256),
    3, 0x92, 0x3f, (unsigned char)(T3_HFP / 256),
    /*
     * reg[0x43] is checksums, it will be changed
     * after reg[0x45] or reg[0x47] changed.
     * regs 0x43, 0x44, 0x45, 0x47 total sum is 0x6F.
     */
    3, 0x94, 0x43, 0x33,
    3, 0x94, 0x47, T3_VIC,
};

EI_S32 panel_lt8912b_get_panel_attr(PANEL_TYPE_E enPanelType, PANEL_TYPE_ATTR_S *pstPanelAttr)
{
    switch (enPanelType) {
    case LT8912B_MIPI_720_480_60FPS:
        pstPanelAttr->stVoPubAttr = lt8912b_720_480_60_config;
	break;
    case LT8912B_MIPI_1280_720_50FPS:
        pstPanelAttr->stVoPubAttr = lt8912b_1280_720_50_config;
	break;
    case LT8912B_MIPI_1920_1080_60FPS:
        pstPanelAttr->stVoPubAttr = lt8912b_1920_1080_60_config;
	break;
    default:
        EI_TRACE_DOSS(EI_DBG_INFO, "invalid panel id\n");
        return EI_ERR_VO_ILLEGAL_PARAM;
    }

    return EI_SUCCESS;
}

EI_S32 panel_lt8912b_get_panel_init_code(PANEL_TYPE_E enPanelType, PANEL_INIT_CODE_TYPE *init, EI_U32 *pLen)
{
    switch (enPanelType) {
    case LT8912B_MIPI_720_480_60FPS:
        *init = &lt8912b_480P_init_code[0];
        *pLen = EI_ARRAY_SIZE(lt8912b_480P_init_code);
	break;
    case LT8912B_MIPI_1280_720_50FPS:
        *init = &lt8912b_720P_init_code[0];
        *pLen = EI_ARRAY_SIZE(lt8912b_720P_init_code);
	break;
    case LT8912B_MIPI_1920_1080_60FPS:
        *init = &lt8912b_1080P_init_code[0];
        *pLen = EI_ARRAY_SIZE(lt8912b_1080P_init_code);
	break;
    default:
        EI_TRACE_DOSS(EI_DBG_INFO, "invalid panel id\n");
        return EI_ERR_VO_ILLEGAL_PARAM;
    }

    return EI_SUCCESS;
}

PANEL_OBJ_S stPanelLt8912bObj = {
    .pfnGetPanelAttrByPanel = panel_lt8912b_get_panel_attr,
    .pfnGetPanelInitCodeByPanel = panel_lt8912b_get_panel_init_code,
};

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

